package com.cashmanager.client.datasource;

import com.cashmanager.client.view.AppConstants;
import com.cashmanager.shared.vo.Cash;
import com.cashmanager.shared.vo.URL_PARAM;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;

public class CashDataSource extends DataSource{
   private static CashDataSource instance = null;
    
    public static CashDataSource getInstance() {
        if (instance == null) {
          instance = new CashDataSource("countryDS_XML");
        }	
        return instance;
    }

    private CashDataSource(String id) {
        setID(id);
        setDataFormat(DSDataFormat.XML);
        setRecordXPath("/List/Record");
        
        DataSourceTextField seq = new DataSourceTextField(Cash.Fields.SEQ, "序号");
        DataSourceTextField machineNo = new DataSourceTextField(Cash.Fields.CASHIER_CDE, "机器号");
//        DataSourceTextField cang = new DataSourceTextField("cang", "仓号");
        DataSourceTextField operator = new DataSourceTextField(Cash.Fields.OPERATOR_CDE, "操作员号");
        DataSourceTextField branch = new DataSourceTextField(Cash.Fields.BRANCH_CDE, "操作员号");
        DataSourceTextField cardNo = new DataSourceTextField(Cash.Fields.CARD_NO, "储户卡号");
        DataSourceTextField number = new DataSourceTextField(Cash.Fields.UID, "冠字号");
        DataSourceTextField type = new DataSourceTextField(Cash.Fields.CURRENCY_CDE, "币种");
        DataSourceTextField value = new DataSourceTextField(Cash.Fields.FACE_VALUE, "面值");
        DataSourceTextField version = new DataSourceTextField(Cash.Fields.VERSION, "版别");
//        DataSourceTextField secLine = new DataSourceTextField("secLine", "鉴伪安全线");
//        DataSourceTextField  light = new DataSourceTextField("light", "鉴伪荧光");
//        DataSourceTextField redLight = new DataSourceTextField("redLight", "鉴伪红外");
//        DataSourceTextField dirty = new DataSourceTextField("dirty", "清分赃污");
//        DataSourceTextField broken = new DataSourceTextField("broken", "清分破损");
        
        
        setFields(seq, 
      		  machineNo, 
//      		  cang,
      		  number, 
      		  operator,
      		  cardNo,
      		  branch,
      		  type, 
      		  value,
      		  version
//      		  secLine, 
//      		  light,
//      		  redLight, 
//      		  dirty, 
//      		  broken
      		 );
      		  
        setDataURL(GWT.getModuleBaseURL()+"xmlservlet?param="+URL_PARAM.CASH_URL_PARAM);
    }
}
